<template>
	<view class="content">
		<view class="myhead">
			<view class="mydefault" v-if="token ==''" @click="tzlogin">
				<image src="../../static/mrtx.jpg" class="mrimg" mode=""></image>
				微信用户
			</view>
			<view class="mydefault" v-else style="display: flex;align-items: center">
				<view class="avatar" style="margin-right: 15px;">
					<image :src="userinfo.avatar" class="mrimg" mode=""></image>

				</view>
				{{userinfo.nickname}}
			</view>

		</view>
		<view class="mytitle">我的内容</view>
		<view class="mycontent">
			<view class="mylist" @click="shioucang">
				<view><uni-icons type="shop" size="24" color="#a1a7b2"></uni-icons></view>
				<view>收藏</view>
			</view>
			<view class="mylist">
				<view><uni-icons type="shop" size="24" color="#a1a7b2"></uni-icons></view>
				<view>作业</view>

			</view>
			<view class="mylist">
				<view><uni-icons type="shop" size="24" color="#a1a7b2"></uni-icons></view>
				<view>笔记</view>

			</view>
			<view class="mylist">
				<view><uni-icons type="shop" size="24" color="#a1a7b2"></uni-icons></view>
				<view>收藏</view>

			</view>
		</view>

		<view class="mytitle">我的账号</view>
		<view class="mycontent">
			<view class="mylist">
				<view><uni-icons type="shop" size="24" color="#a1a7b2"></uni-icons></view>
				<view>订单</view>
			</view>
			<view class="mylist">
				<view><uni-icons type="shop" size="24" color="#a1a7b2"></uni-icons></view>
				<view>优惠券</view>

			</view>
			<view class="mylist">

			</view>
			<view class="mylist">

			</view>
		</view>
		<view class="mytitle1" @click="tcdl">退出登录</view>
	</view>
</template>
<style>
	.mytitle1 {
		padding: 20rpx;
		text-align: center;
		background: #fff;
		margin-top: 20rpx;
	}

	page {
		width: 100%;
		height: 100%;
	}

	.mylist view {
		text-align: center;
		font-size: 24rpx;
	}

	.mylist {
		width: 25%;
		height: auto;
		float: left;
	}

	.mycontent {
		width: 100%;
		height: auto;
		padding: 20rpx;
		box-sizing: border-box;
		background: #fff;
		overflow: hidden;

	}

	.mytitle {
		margin: 20rpx 0rpx;
		padding-left: 30rpx;
		box-sizing: border-box;
	}

	.mydefault {
		position: absolute;
		bottom: 50rpx;
		left: 50rpx;
	}

	.avatar {
		width: 200rpx;
		height: 200rpx;
		border-radius: 50%;
		border: 1px solid #fff;
		vertical-align: middle;
	}

	.mrimg {
		width: 200rpx;
		height: 200rpx;
		border-radius: 50%;


	}

	.content {
		width: 100%;
		height: 100%;
		background: rgba(239, 239, 239, 0.6901960784);

	}

	.myhead {
		width: 100%;
		height: 340rpx;
		background: url("../../static/banner1.jpg") no-repeat;
		background-size: 100% 100%;
		position: relative;
	}
</style>
<script setup>
	import {
		onShow
	} from '@dcloudio/uni-app';
	import {
		ref
	} from 'vue';
	import instance from '../../request';

	onShow(() => {


		getdata()


	})
	const token = ref("");
	const shioucang=()=>{
		uni.navigateTo({
			url:"/pages/pingjia/pingjia"
		})
	}
	const userinfo = ref({});
	const getdata = () => {
		if (uni.getStorageSync("token")) {
			token.value = uni.getStorageSync("token");

			console.log(token.value)
			getuserinfo()
		} else {
			token.value = ""
		}



	}
	const getuserinfo = async () => {
		const res = await instance.get("/api/ucenter/member/auth/getLoginInfo");
		console.log(res)
		userinfo.value = res.data.item
		console.log(userinfo.value)
	}

	const tzlogin = () => {
		uni.navigateTo({
			url: "/pages/login/login"
		})
	}
	const tcdl = () => {
		uni.navigateTo({
			url: "/pages/login/login"
		})
		uni.clearStorageSync()
	}
</script>

<style>

</style>